package com.zx.tradeclient.ctrl.index3;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;

import com.zx.base.ctrl.BaseActivity;
import com.zx.base.ctrl.Constant;
import com.zx.base.util.ActivityTaskManager;
import com.zx.base.widget.QuitDialog;
import com.zx.tradeclient.app.TradeApp;
import com.zx.tradeclient.ctrl.index4.Index4Activity;
import com.zx.tradeclient.ctrl.index5.LoginActivity;
import com.zx.tradeclient.ctrl.index5.OrderPageActivity;

public class Index3Activity extends BaseActivity{
	/** Called when the activity is first created. */

	private TradeApp app;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		if (!(ActivityTaskManager.getInstance().containsName("Index3Activity"))) {
			ActivityTaskManager.getInstance().putActivity("Index3Activity",
					this);
		}

		app = (TradeApp) getApplication();

		if (app.user.getId() == null || app.user.getId().equals("")) {
			Intent intent = new Intent(Index3Activity.this, LoginActivity.class);
			startActivity(intent);
		} else {
			Intent intent = new Intent(Index3Activity.this, OrderPageActivity.class);
			startActivity(intent);
		}

	}

	
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if (Constant.debug)
				Log.d("TMG", "ManageActivity KEYCODE_BACK");
			QuitDialog dialog = new QuitDialog(Index3Activity.this);
			dialog.exitConfirm();

			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

}